/**
 * 
 */
package com.chinaums.cfps.apps.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.chinaums.ibmmq.MQMessageListener;
import com.chinaums.ibmmq.MQMsg;

/**
 * MQ 业务实现父类.
 * @author 磊
 *
 */
public abstract class AbstractCfpsMQMessageListener implements MQMessageListener{
	private final static Logger LOGGER = LoggerFactory.getLogger(AbstractCfpsMQMessageListener.class);
	public boolean isOk;
	
	public void onMessage(MQMsg paramMQMsg) {
		try {
			String data = paramMQMsg.getMsg();
			if(null == data || "".equals(data)){
				LOGGER.info("接收到数据为空");
				return;
			}
			this.execute(data);
		} catch(Exception e) {
			LOGGER.error(e.toString());
			isOk = false;
		}
		
	}
	/**
	 * 数据处理，需要子类实现.
	 * @param data
	 */
	public abstract void execute(String data);
	/**
	 * 停止事件回调.
	 */
	public abstract void stopEvent();
	/**
	 * 判断监听器是否有问题
	 */
	public abstract boolean isOk();
}
